<script setup>
// 第三方模块
import { useRouter } from "vue-router";
const router = useRouter();

// 自定义模块
// 仓库
import useUserStore from "@/stores/user";
import { computed } from "vue";
const userStore = useUserStore();

// console.log(userStore.userList);

// 查询用户地址
let res = computed(() => {
  return userStore.userList.find((item) => item.name === "zhangsan");
});

// 对当前地址赋值
const getCurAddress = (index) => {
  res.value.currentAddress = res.value.addressList[index];
  router.go(-1);
};
</script>

<template>
  <div class="card" v-for="(item, index) in res.addressList" @click="getCurAddress(index)">
    <div class="info">
      <div class="name">{{ item.name }}</div>
      <div class="tel">{{ item.phone }}</div>
    </div>
    <div class="address_text">
      {{ item.address_text }}
    </div>
  </div>
</template>

<style lang="scss" scoped>
@import "@/style/viriables.scss";
.card {
  margin: 0.18rem;
  padding: 0.18rem;
  background-color: $bgColor;
  border-radius: 0.04rem;
  font-size: 0.14rem;

  .info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.08rem;
    color: $light-fontColor;

    div {
      flex: 1;
    }
  }
}
</style>